package com.cxrj.zhsq.propertyManage.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cxrj.zhsq.propertyManage.entity.PropertyPayment;
import com.cxrj.zhsq.propertyManage.service.PropertyPaymentService;

@RestController
public class PropertyPaymentController {

	@Resource
	private PropertyPaymentService propertyPaymentService;

	/**
	 * 根据code查询缴费配置
	 * 
	 * @return
	 */
	@RequestMapping(value = "selectPropertyPaymentByCode", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> selectPropertyPaymentByCode(String code, HttpServletRequest request) {
		return propertyPaymentService.selectPropertyPaymentByCode(code, request.getSession().getAttribute("communityId").toString());
	}

	/**
	 * 添加通知
	 * 
	 * @return
	 */
	@RequestMapping(value = "insertPropertyPayment", method = RequestMethod.POST)
	public Map<String, Object> insertPropertyPayment(PropertyPayment propertyPayment, HttpServletRequest request) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			propertyPayment.setCommunityId(request.getSession().getAttribute("communityId").toString());
			resultMap = propertyPaymentService.insertPropertyPayment(propertyPayment);
		} catch (Exception e) {
			resultMap.put("result", 0);
			e.printStackTrace();
		}
		return resultMap;
	}
}
